#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Solution {
public: 
	vector<int> bestCoordinate(vector<vector<int>>& towers, int radius) { 
		int NO_SET = -1;
		int sig, max_sig;
		double d;
		int min_x, min_y;
		max_sig = -1;
		min_x = min_y = NO_SET;
		int x1, x2, y1, y2;
		x1 = x2 = y1 = y2 = 0;
		for(int t = 0; t < towers.size(); t++){
			if(t == 0){
				x1 = x2 = towers[t][0];
				y1 = y2 = towers[t][1];
			}
			if(x1 > towers[t][0]) x1 = towers[t][0];
			if(x2 < towers[t][0]) x2 = towers[t][0];
			if(y1 > towers[t][1]) y1 = towers[t][1];
			if(y2 < towers[t][1]) y2 = towers[t][1];
		}
		const bool debug = false;
		//printf("[%d,%d] x [%d,%d]\n", x1, x2, y1, y2);
		//for(int x = x1; x <= x2; x++){
			//for(int y = y1; y <= y2; y++){
		for(int i = 0; i < towers.size(); i++){
			int x = towers[i][0];
			int y = towers[i][1];
			sig = 0;
			if(debug) printf("x,y == %d,%d\n", x, y);
			for(int t = 0; t < towers.size(); t++){
				d = dist(x, y, towers[t][0], towers[t][1]);
				if(d > radius) continue;
				int cur_sig = floor(towers[t][2] / (1 + d));
				sig += cur_sig;
				if(debug) printf("  x2,y2 == %d,%d cur_sig=%d sig=%d d=%d\n", towers[t][0], towers[t][1], cur_sig, sig, d);
			}
			if(max_sig < sig){
				max_sig = sig;
				min_x = x;
				min_y = y;
			}else if(max_sig == sig && less(x, y, min_x, min_y)){
				min_x = x;
				min_y = y;
			}
			//if(debug) printf("[%d,%d]=%d\n", x, y, sig);
		}
			//}
		//}
		if(debug) printf("max_sig = %d\n", max_sig);
		vector<int> ans;	
		ans.push_back(min_x);
		ans.push_back(min_y);
		return ans;
	}

	//欧几里得距离
	double dist(int x1, int y1, int x2, int y2){
		return sqrt(double((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));	
	}

	bool less(int x1, int y1, int x2, int y2){
		if(x1 != x2) return x1 < x2;
		return y1 < y2;
	}
		
};

int main(int argc, char* argv[])
{
	Solution s;
	const int ROW = 11, COL = 3;
	int a[ROW][COL] = {
		{31,13,33},{24,45,38},{28,32,23},{7,23,22},{41,50,33},{47,21,3},{3,33,39},{11,38,5},{26,20,28},{48,39,16},{34,29,25}
	};
	vector<vector<int>> towers;
	for(int i = 0; i < ROW; i++){
		vector<int> r;
		for(int j = 0; j < COL; j++){
			r.push_back(a[i][j]);
		}
		towers.push_back(r);
	}
	int radius = 21;
	vector<int> ans = s.bestCoordinate(towers, radius);
	printf("[%d,%d]\n", ans[0], ans[1]);
    return 0;
}
